/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.br.siseduca.application;

import com.br.siseduca.domain.Region;
import com.br.siseduca.service.RegionService;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Inject;

/**
 *
 * @author danieldamian
 */
@Named(value = "registeringRegion")
@RequestScoped
public class RegisteringRegion {

    @Inject
    private Region region;
    @Inject
    private RegionService regionService;
    /**
     * Creates a new instance of RegisteringRegion
     */
    public RegisteringRegion() {
    }

    public Region getRegion() {
        return region;
    }

    public void setRegion(Region region) {
        this.region = region;
    }
    
    public String registering() {
        
        regionService.create(region);
        FacesContext facesContext = FacesContext.getCurrentInstance();
        FacesMessage facesMessage = new FacesMessage();
        facesMessage.setSeverity(FacesMessage.SEVERITY_INFO);
        facesMessage.setSummary("Cadastro realizado com sucesso!"); //refatorar
        facesContext.addMessage(null, facesMessage);
        return null;
    }
}
